Add periods in a string [closed]
Posted
by
Garling Beard
on Stack Overflow
See other posts from Stack Overflow
or by Garling Beard
Published on 2014-06-06T21:58:49Z
Indexed on
2014/06/13
3:26 UTC
Read the original article
Hit count: 52
I'm unable to determine why I don't get my expected output, given this code:
int periods = (location.Length / 2) - 1;
for (int index = 2, i = 0; i < periods; index += 3, ++i )
{
location = location.Insert(index, ".");
}
And a location
of "C5032AC"
, I expect that location
will equal "C.50.32.A.C"
after my loop terminates; it is instead "C5.03.2AC"
. Can anyone explain what I'm missing here?
© Stack Overflow or respective owner